#include "lexer.hxx"
#include "keywordList.hxx"

Lexer::Lexer() {}
Lexer::~Lexer() {}

int Lexer::inter(string text)
{
    this->code = text;
    cout << nextWord(this->ThisOne) << endl;
    return 0;
}

Token Lexer::searchForToken (Token tklist[], string cnt) {

}

void Lexer::skipSpace(ReadHead &rh)
{
    while (rh.charNum <= this->code.length())
    {
        rh.charCnt = this->code[rh.charNum];
        if (rh.charCnt == ' ' || rh.charCnt == '\n' || rh.charCnt == '\t')
        {
            
            rh.charNum += 1;
        }
        else
        {
            break;
        }
    }
}

Token Lexer::nextToken(ReadHead &rh)
{
    this->skipSpace(rh);
    string temp = "";

    while (rh.charNum <= this->code.length())
    {
        rh.charCnt = this->code[rh.charNum];
        if (!(rh.charCnt == ' ' || rh.charCnt == '\n' || rh.charCnt == '\t'))
        {
            temp.append(string(1, rh.charCnt));
            rh.charNum += 1;
        }
        else
        {
            rh.charNum += 1;
            break;
        }
    }
    Token res = 
    return 
    // TODO: 在关键字清单里建立所有关键字的索引 (vector)
    // TODO: 利用switch匹配关键字 (记得加上break)
    // TODO: 测试nextTk()和skipSpace()两个函数
}
